package com.v1.video.domain;

import org.json.JSONObject;

import android.content.ContentValues;
import android.database.Cursor;
import android.os.Handler;

import com.iss.bean.BaseBean;
import com.iss.db.TableColumn;
import com.v1.video.option.util.DownloadAppUtil.DownAppRunnable;


/**
 * 设置-应用推荐
 * @author Administrator
 *
 */
public class RecommendAppInfo extends BaseBean<RecommendAppInfo>{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    
    @TableColumn(type = TableColumn.Types.TEXT)
    public String appName = "";
    @TableColumn(type = TableColumn.Types.TEXT)
    public String appDetail = "";
    @TableColumn(type = TableColumn.Types.TEXT)
    public String imgUrl = "";
    @TableColumn(type = TableColumn.Types.TEXT)
    public String appUrl = "";
    @TableColumn(type = TableColumn.Types.TEXT)
    public String packageName = "";//包名
    @TableColumn(type = TableColumn.Types.TEXT)
    public String appType = "";//区分android还是ios
    @TableColumn(type = TableColumn.Types.TEXT)
    public String create_date = "";
    @TableColumn(type = TableColumn.Types.TEXT)
    public String appSize = "";
    @TableColumn(type = TableColumn.Types.TEXT)
    public String saveFilePath = "";//保存路径 ----
    @TableColumn(type = TableColumn.Types.TEXT)
    public String appTitle = "";
    @TableColumn(type = TableColumn.Types.INTEGER)
    public int totalSize = 0;
    @TableColumn(type = TableColumn.Types.TEXT)
    public String classMain = "";
    @TableColumn(type = TableColumn.Types.INTEGER)
    public int state = 0;//0未读，1已读；
    @TableColumn(type = TableColumn.Types.INTEGER)
    public int status = 0;// 0:未开始下载；1：正在下载；2：已经停止；3：已经下载;4:失败；5:删除
    @TableColumn(type = TableColumn.Types.INTEGER)
    public int progress = 0;
    
//    /**0未下载1下载部分2下载 完成，未安装 3已安装*/
//    public int state = 0;
//    public static final int STATE_GO_DOWN = 0;
//    public static final int STATE_GO_CONTINUE = 1;
//    public static final int STATE_GO_INSTALL = 2;
//    public static final int STATE_GO_START = 3;
    
    public RecommendAppInfo(){
        
    }
    
    public RecommendAppInfo(RecommendInfoApp info){
        this.appDetail = info.getAppDetail();
        this.appName = info.getAppName();
        this.appSize = info.getAppSize();
        this.imgUrl = info.getImgUrl();
        this.appUrl = info.getAppUrl();
        this.appTitle = info.getAppTitle();
        this.appType = info.getAppType();
        this.packageName = info.getPackageName();
        this.create_date = info.getCreate_date();
        this.saveFilePath = info.getSaveFilePath();
        this.totalSize = info.getTotalSize();
        this.classMain = info.getClassMain();
        this.status = info.getStatus();
        this.state = info.getState();        
    }
    
    @Override
    public RecommendAppInfo cursorToBean(Cursor cursor) {
        // TODO Auto-generated method stub
//        return null;
        appName = cursor.getString(cursor.getColumnIndex("appName"));
        appDetail = cursor.getString(cursor.getColumnIndex("appDetail"));
        imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
        appUrl = cursor.getString(cursor.getColumnIndex("appUrl"));
        packageName = cursor.getString(cursor.getColumnIndex("packageName"));
        appType = cursor.getString(cursor.getColumnIndex("appType"));        
        create_date = cursor.getString(cursor.getColumnIndex("create_date"));
        appSize = cursor.getString(cursor.getColumnIndex("appSize"));
        saveFilePath = cursor.getString(cursor.getColumnIndex("saveFilePath"));
        status = cursor.getInt(cursor.getColumnIndex("status"));
        appTitle = cursor.getString(cursor.getColumnIndex("appTitle"));
        totalSize = cursor.getInt(cursor.getColumnIndex("totalSize"));
        classMain = cursor.getString(cursor.getColumnIndex("classMain"));
        state = cursor.getInt(cursor.getColumnIndex("state"));
        progress = cursor.getInt(cursor.getColumnIndex("progress"));
        return this;
    }
            
    @Override
    public ContentValues beanToValues() {
        // TODO Auto-generated method stub
        ContentValues values = new ContentValues();
        values.put("appName", appName);
        values.put("appDetail", appDetail);
        values.put("imgUrl", imgUrl);
        values.put("appUrl", appUrl);
        values.put("packageName", packageName);
        values.put("appType", appType);        
        values.put("appSize", appSize);
        values.put("create_date", create_date);
        values.put("saveFilePath", saveFilePath);
        values.put("status", status);
        values.put("appTitle", appTitle);
        values.put("totalSize", totalSize);
        values.put("classMain", classMain);
        values.put("state", state);
        values.put("progress", progress);
        return values;
    }
    
//    /**状态：0 未下载，1：已下载，未安装，2：已安装*/
//    private int state = 0;//
    
    
    public String getAppName() {
        return appName;
    }
    
    public int getStatus() {
        return status;
    }
    public void setStatus(int status) {
        this.status = status;
    }
    
    public void setAppName(String appName) {
        this.appName = appName;
    }
    public String getAppSize() {
        return appSize;
    }
    public void setAppSize(String appSize) {
        this.appSize = appSize;
    }
    public String getAppDetail() {
        return appDetail;
    }
    public void setAppDetail(String appDetail) {
        this.appDetail = appDetail;
    }
    public String getImgUrl() {
        return imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
    public String getAppUrl() {
        return appUrl;
    }
    public void setAppUrl(String appUrl) {
        this.appUrl = appUrl;
    }
    public String getCreate_date() {
        return create_date;
    }
    public void setCreate_date(String create_date) {
        this.create_date = create_date;
    }
    
    public String getPackageName() {
        return packageName;
    }
    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }
    public String getAppType() {
        return appType;
    }
    public void setAppType(String appType) {
        this.appType = appType;
    }
    
    public String getSaveFilePath() {
        return saveFilePath;
    }
    public void setSaveFilePath(String saveFilePath) {
        this.saveFilePath = saveFilePath;
    }
    
    public String getAppTitle() {
        return appTitle;
    }
    public void setAppTitle(String appTitle) {
        this.appTitle = appTitle;
    }
    
    public String getClassMain() {
        return classMain;
    }
    public void setClassMain(String classMain) {
        this.classMain = classMain;
    }
    
    public int getTotalSize() {
        return totalSize;
    }
    public void setTotalSize(int totalSize) {
        this.totalSize = totalSize;
    }
    @Override
    public JSONObject toJSON() {
        // TODO Auto-generated method stub
        return null;
    }


    @Override
    public RecommendAppInfo parseJSON(JSONObject jsonObj) {
        // TODO Auto-generated method stub
        return null;
    }
    
    public Handler mHandler;
    
    public long currSize = 0;
    
    public static final int STATUS_DOWNNING = 1;
    public static final int STATUS_STOP = 2;
    public static final int STATUS_DOWNED = 3;
    public static final int STATUS_FAILED = 4;
    public static final int STATUS_DELETE = 5;
    public static final int STATUS_GO_DOWN = 6;
    public static final int STATUS_GO_START = 7;
 // 下载的线程
    public DownAppRunnable runnable;
    // /////////////////////////////////////////////
    

}
